import axios from "../utils/http";

export function changeHeaderImg(file) {
    let obj = new FormData();//创建表单对象
    obj.append('file',file);
    return axios.post("/api/pcUser/updata/userAvatar",obj)
}
//修改用户昵称
export function changePersonalName(nickname) {
    let obj = {
        "nickname":nickname
    };//创建对象
    return axios.post("/api/pcUser/update/userInfo",obj)
}
//修改用户手机获取验证码
export function changePhoneNumberYanzheng(phoneNumber) {
    return axios.get(`/api/pcUser/short-message/vcode/${phoneNumber}`)
}
//修改用户手机
export function changePersonalPhone(mobile,code) {
    let obj = {
        "mobile":mobile,
        "code":code
    };//创建对象
    return axios.post("/api/pcUser/update/userMobile",obj)
}
//修改密码获取验证码
export function getChangePersonalToPasswordCode(phoneNumber) {
    return axios.get(`/api/pcUser/edit-password/send/code/${phoneNumber}`)
}

//修改密码
export function changePersonalToNewPassword(oldPassword,newPassword,checkNewPassword,mobile,code) {
    let obj2 = new URLSearchParams();//创建表单对象
    obj2.append('oldPassword',oldPassword);
    obj2.append('newPassword',newPassword);
    obj2.append('checkNewPassword',checkNewPassword);
    obj2.append('mobile',mobile);
    obj2.append('code',code);
    return axios.post("/api/pcUser/update/userPassword",obj2)
}